function y = China_solve_imb(X,r,lambda_b,lambda_g,gamma,theta_b,theta_g,p,q,theta_bb,theta_gg,r_hat,U)

x_b = X(1);
y_b = X(2);
x_g = X(3);
y_g = X(4);

C_xb = (1-gamma)*x_b + gamma*((x_b + y_b)^2);
C_xg = (1-gamma)*x_g + gamma*((x_g + y_g)^2);
C_yb = (1-gamma)*y_b + gamma*((x_b + y_b)^2);
C_yg = (1-gamma)*y_g + gamma*((x_g + y_g)^2);

V_b = p - 2 *q *(y_b + y_g);
V_g = p - 2 *q *(y_b + y_g);
m_b = p - 2 *q *(y_b);                        % derivative of boy's payoff w.r.t public investment evaluated at boy's public investment and zero girl public investment 
rho = (1-r)/(1-r_hat);


y1 = C_xb - lambda_b - (1-lambda_g)*theta_b - rho*((1-r_hat)*(1-lambda_b) + (1-lambda_g)*(r_hat*theta_bb - theta_b) + U);
y2 = C_xg - lambda_g - (1-lambda_b)*(rho*theta_gg + (1-rho)*theta_g);
y3 = C_yb - V_b - ((1-lambda_g)/(1-lambda_b))*theta_b*V_g - rho*((1-r_hat)*(m_b - V_b) + ((1-lambda_g)/(1-lambda_b))*V_g*(r_hat*theta_bb - theta_b) + (U*V_g)/(1-lambda_b));
y4 = C_yg - V_g - ((1-lambda_b)/(1-lambda_g))*V_b*(rho*theta_gg + (1-rho)*theta_g);

y = sqrt(y1^2 + y2^2 + y3^2 + y4^2);

